package org.example.src.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;

@Entity
@Table(name = "students")
@Data
@EqualsAndHashCode(callSuper = true)
public class Student extends User {
    @Id
    private Long userId;

    @OneToOne
    @MapsId
    @JoinColumn(name = "user_id")
    private User user;

    @Column(name = "student_id", unique = true)
    private String studentId;

    @Column(name = "full_name")
    private String fullName;

    private String major;

    private Integer grade;

    @Column(name = "class_name")
    private String className;

    @Column(columnDefinition = "TEXT")
    private String resume;

    @Column(name = "profile_picture")
    private String profilePicture;

    @OneToMany(mappedBy = "student", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<Application> applications;

    @OneToMany(mappedBy = "student", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<WeeklyReport> weeklyReports;

    @OneToMany(mappedBy = "student", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<FinalReport> finalReports;

    @OneToMany(mappedBy = "student", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<Feedback> feedbacks;

    protected void onCreate() {
        super.onCreate();
        this.setRole("STUDENT");
    }

    protected void onUpdate() {
        super.onUpdate();
    }
}
